<template>
    <ui-main>
        <ui-pull @load="getListData" v-model="listData" :total="total" :num.sync="pageNumber" ref="pull">
            <div class="flex row-between col-center bg-white pl5 pt10 pr5 pb10 ui-border-bottom" v-for="(item,index) of listData" :key="index" @click="detail(item)">
                <div class="t-b">{{item.notice_title}}</div>
                <div class="ml5"><i class="fa fa-angle-right f20"></i></div>
            </div>
        </ui-pull>
    </ui-main>
</template>

<script>
    import cy from '../mixins/cy';

    export default {
        mixins: [cy],
        data() {
            return {
                // 数据源
                listData: [],
                // 其他
                pageNumber: 1,
                pageSize: 20,
                total: 0
            };
        },
        mounted() {
            this.$title('公文公告');
        },
        methods: {
            getListData({isDownScrolling}) {
                this.$$getNoticeReceiveList({
                    customer_id: this.$user.customer_id,
                    pageNumber: this.pageNumber,
                    pageSize: this.pageSize
                }).then(data => {
                    this.pageNumber++;
                    this.total = data.total;

                    if (isDownScrolling) {
                        this.listData = data.content;
                    } else {
                        this.listData = [...this.listData, ...data.content];
                    }

                    this.$refs.pull && this.$refs.pull.endSuccess();
                }).catch(e => {
                    console.error(e);
                });
            },
            detail(item) {
                this.$router.push({
                    path: '/gwggmx',
                    query: {
                        notice_id: item.id
                    }
                });
            }
        }
    }
</script>
